/*     */ package com.qmsk.business.info.shopType.controller;
/*     */ 
/*     */ import com.qmsk.business.info.shopType.dao.ShopTypeDAO;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/shopType"})
/*     */ public class ShopTypeController
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(ShopTypeController.class);
/*     */ 
/*     */   @Autowired
/*     */   private ShopTypeDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/page/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  47 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  49 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  50 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  52 */       logger.error(e);
/*  53 */       ResponseUtils.setErrorMsgResponse(
/*  54 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  72 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  74 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  75 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  77 */       logger.error(e);
/*  78 */       ResponseUtils.setErrorMsgResponse(
/*  79 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  95 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/*  97 */       int nResult = 0;
/*  98 */       ParserDataSetJson p = ParserDataSetJson.fromString(sGsonInData);
/*  99 */       if (p != null) {
/* 100 */         nResult = this.dao.applyUpdates(p);
/* 101 */         if (nResult > 0)
/* 102 */           DbConnection.commit();
/*     */         else {
/* 104 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 107 */       DbConnection.commit();
/* 108 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 109 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 110 */         response);
/*     */     } catch (Exception e) {
/* 112 */       DbConnection.rollback();
/* 113 */       logger.error(e);
/* 114 */       ResponseUtils.setErrorMsgResponse(
/* 115 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 116 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 132 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 134 */       String[] strParams = id.split(",");
/* 135 */       int nResult = this.dao.deleteParams(strParams);
/* 136 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 137 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 138 */         response);
/* 139 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 141 */       DbConnection.rollback();
/* 142 */       logger.error(e);
/* 143 */       ResponseUtils.setErrorMsgResponse(
/* 144 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 145 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 161 */     String sData = RequestUtils.getStringOfData(request);
/*     */     try {
/* 163 */       int nResult = 0;
/* 164 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 165 */       if (p != null) {
/* 166 */         nResult = this.dao.applyUpdates(p);
/* 167 */         if (nResult > 0)
/* 168 */           DbConnection.commit();
/*     */         else {
/* 170 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 174 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 175 */         RequestUtils.getSqlUpdateErrorMessage(sData, request), 
/* 176 */         response);
/*     */     } catch (Exception e) {
/* 178 */       DbConnection.rollback();
/* 179 */       logger.error(e);
/* 180 */       ResponseUtils.setErrorMsgResponse(
/* 181 */         RequestUtils.getSqlUpdateErrorMessage(sData, request) + 
/* 182 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.shopType.controller.ShopTypeController
 * JD-Core Version:    0.5.3
 */